/*

 *说明*

 和HeadView区别在于返回和关闭的事件需要自己绑定

 */
define(['./BaseView', 'jquery'], (BaseView, $)=> {
    require('../../less/header.less');

    return BaseView.extend({
        type: "HeadView",
        events: {
            'click .left': 'back',
        },
        initialize: function () {
            var me = this;
        },
        back: function () {
            $('.close-window').show();
            window.pageIndex = 1;
        },
        render: function () {
            let lt = this.options.leftIcon;
            let rt = this.options.rightIcon;
            let nPage = this.currentPage.id;
            let closeWord = this.options.closeWord || '关闭';
            let closeStyle = window.pageIndex === 1 ? '"display: table"' : '"display: none"';
            let leftWord = this.options.leftWord ? this.options.leftWord : '';
            let rightWord = this.options.rightWord ? this.options.rightWord : '';
            let leftIcon = this.options.leftIcon ? '<i class="' + lt + '"></i>' : '<i class="icon-back"></i>';
            let rightIcon = this.options.rightIcon ? '<i class="' + rt + '"></i>' : '';
            let html = `<div class="headview">
                <div class="left">
                    ${leftIcon}
                    <span>${leftWord}</span>
                </div>
                <div class="close-window" style=${closeStyle}>
                    <span>${closeWord}</span>
                </div>
                 <h1 class="title">${this.options.titleName}</h1>
                <div class="right">
                    <span>${rightWord}</span>
                    ${rightIcon}
                    </div>
            </div>`;
            this.$el.append(html);
            return this;
        },

    });

});
